import axios from "../utils/axios"
//登陆
const loginApi=async (_data:{username:string,password:string})=>{
    const data=await axios({
        url:'/admin/login',
        method:'post',
        data:_data
    })
    return data;
}
//管理员添加
const signUpApi=async (_data:{email:string,imageUrl:string,name:string,phone:string,username:string,password:string,password2:string})=>{
    const data=await axios({
        url:'/admin/add',
        method:'post',
        data:_data
    })
    return data;
}
//管理员渲染
const adminListApi=async ()=>{
    const data=await axios({
        url:'/admin/findAll',
        method:'get',
    })
    return data;
}
//管理员查询
const adminQueryApi=async (_data:{username:string})=>{
    const data=await axios({
        url:'/admin/list',
        method:'post',
        data:_data
    })
    return data;
}
//管理员修改
const adminEditApi=async (_data:{
    email: string,
    id: number,
    imageUrl: string,
    name: string,
    password: string,
    password2: string,
    phone: string,
    username: string
  })=>{
    const data=await axios({
        url:'/admin/update',
        method:'post',
        data:_data
    })
    return data;
}
//管理员删除
const adminDelApi=async (id:number)=>{
    const data=await axios({
        url:'/admin/deleteById?id='+id,
        method:'get',
    })
    return data;
}
//管理员角色权限修改
const adminUpdataApi=async (_data:{adminId:number,roleIds:Array<number>})=>{
    const data=await axios({
        url:'/admin/updateAdminRole',
        method:'post',
        data:_data
    })
    return data;
}
export {
    loginApi,
    signUpApi,
    adminListApi,
    adminQueryApi,
    adminEditApi,
    adminDelApi,
    adminUpdataApi
}